package com.zhenmaitang.clinic_sys.entity;

import java.time.LocalDateTime;
import io.swagger.v3.oas.annotations.media.Schema;

/**
 * 数据权限范围实体类
 */
@Schema(description = "数据权限实体", example = "数据权限规则定义")
public class DataScope {
    @Schema(description = "数据权限ID", example = "1")
    private Integer id;
    
    @Schema(description = "数据权限名称", example = "本部门患者数据", requiredMode = Schema.RequiredMode.REQUIRED)
    private String name;        // 数据权限名称
    
    @Schema(description = "数据权限代码", example = "DEPT_PATIENT_READ", requiredMode = Schema.RequiredMode.REQUIRED)
    private String code;        // 数据权限代码
    
    @Schema(description = "数据权限类型", example = "DEPARTMENT", allowableValues = {"ALL", "DEPARTMENT", "SELF", "CUSTOM"})
    private String type;        // 数据权限类型：ALL-全部数据, DEPARTMENT-本部门数据, SELF-本人数据, CUSTOM-自定义数据
    
    @Schema(description = "资源类型", example = "patient", allowableValues = {"patient", "department", "user", "medical_record"})
    private String resource;    // 资源类型
    
    @Schema(description = "数据权限描述", example = "允许查看本部门的所有患者数据")
    private String description; // 描述
    
    @Schema(description = "是否启用", example = "true", defaultValue = "true")
    private Boolean enabled;    // 是否启用
    
    @Schema(description = "创建时间", example = "2024-01-15 10:30:00")
    private LocalDateTime createTime;
    
    @Schema(description = "更新时间", example = "2024-01-15 14:20:00")
    private LocalDateTime updateTime;

    // 构造函数
    public DataScope() {}

    public DataScope(String name, String code, String type, String resource, String description) {
        this.name = name;
        this.code = code;
        this.type = type;
        this.resource = resource;
        this.description = description;
        this.enabled = true;
        this.createTime = LocalDateTime.now();
        this.updateTime = LocalDateTime.now();
    }

    // Getter和Setter方法
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getResource() {
        return resource;
    }

    public void setResource(String resource) {
        this.resource = resource;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        return "DataScope{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", code='" + code + '\'' +
                ", type='" + type + '\'' +
                ", resource='" + resource + '\'' +
                ", description='" + description + '\'' +
                ", enabled=" + enabled +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}